@echo off
title Cyan-Note Backend Environment Check
echo.
echo =====================================
echo   Cyan-Note Backend Environment Check
echo =====================================
echo.

echo [1] Checking JAVA_HOME environment variable:
if "%JAVA_HOME%"=="" (
    echo    X JAVA_HOME is not set
    echo    Please set JAVA_HOME to JDK 17 installation path
    echo    Example: set JAVA_HOME=C:\Program Files\Java\jdk-17
) else (
    echo    OK JAVA_HOME = %JAVA_HOME%
    if exist "%JAVA_HOME%\bin\java.exe" (
        echo    OK Java executable found
    ) else (
        echo    X Java executable not found at: %JAVA_HOME%\bin\java.exe
    )
)
echo.

echo [2] Checking java command:
java -version >nul 2>&1
if %ERRORLEVEL% equ 0 (
    echo    OK java command is available
    echo    Java version:
    java -version
) else (
    echo    X java command is not available
    echo    Please install JDK 17 and add to PATH
)
echo.

echo [3] Checking javac compiler:
javac -version >nul 2>&1
if %ERRORLEVEL% equ 0 (
    echo    OK javac compiler is available
    javac -version
) else (
    echo    X javac compiler is not available
    echo    Please install JDK (not just JRE)
)
echo.

echo [4] Checking Maven:
mvn -version >nul 2>&1
if %ERRORLEVEL% equ 0 (
    echo    OK Maven is available
    mvn -version | findstr "Apache Maven"
) else (
    echo    X Maven is not available
    echo    Please install Apache Maven from: https://maven.apache.org/download.cgi
)
echo.

echo [5] Checking project structure:
if exist "pom.xml" (
    echo    OK pom.xml found
) else (
    echo    X pom.xml not found
    echo    Please run this script from the backend directory
)
echo.

echo =====================================
echo Summary
echo =====================================
echo.
echo If you see X marks above, please fix them:
echo.
echo 1. Install JDK 17 from:
echo    https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html
echo.
echo 2. Set JAVA_HOME environment variable:
echo    Right-click This PC - Properties - Advanced System Settings - Environment Variables
echo    Add system variable: JAVA_HOME = C:\Program Files\Java\jdk-17
echo.
echo 3. Add to PATH environment variable:
echo    Add to system PATH: %%JAVA_HOME%%\bin
echo.
echo 4. Install Apache Maven and add to PATH
echo.
echo 5. Restart command prompt and try again
echo.
echo Press any key to close...
pause >nul